﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using PrinterBudi.Persistence;

namespace PrinterBudi.Web.Controllers
{
    public class HomeController : Controller
    {
        //
        // GET: /Home/

        public ActionResult Index()
        {
            if (Session["userId"] != null)
            {
                PBUser user = PBUserModel.Read((int)Session["userId"]);
                ViewBag.completeName = user.Name;
                ViewBag.phNumber = user.PhoneNumber;
            }
            return View();
        }

        public ActionResult Login()
        {
            return View();
        }

        public ActionResult Register()
        {
            return View();
        }

        public ActionResult Profile()
        {
            if (Session["userId"] == null)
                return Redirect("/Home");
            PBUser user = PBUserModel.Read((int)Session["userId"]);
            ViewBag.completeName = user.Name;
            ViewBag.address = user.Address;
            return View();
        }

        public ActionResult Upload()
        {
            if (Session["userId"] == null)
                return Redirect("/Home");
            return View();
        }

        public ActionResult Logout()
        {
            Session.Clear();
            return Redirect("/Home");
        }
    }
}
